<template>
  <div class="bancode-scan-setting">
    <div class="divider-empty-thin"></div>
    <span class="title">
      {{ $srv.getI18nByPath('oSetupPanel.SetupAttrDetail.bancodeScan') }}
    </span>
    <div class="setting-item">
      <div class="db-label-value">
        <div class="label-value">
          <span>{{ $srv.getI18nByValue('开启') }}</span>
          <vxe-switch
            v-model="config.enable"
            size="default"
            :open-label="$srv.getI18nByValue('启用')"
            :close-label="$srv.getI18nByValue('禁用')"
            @change="saveDetailToConfig"
          ></vxe-switch>
          <!-- <Switch
                  v-model="config.enable"
                  size="default"
                  @on-change="saveDetailToConfig"
                /> -->
        </div>
        <div class="label-value">
          <span>{{ $srv.getI18nByValue('初始间距') }}</span>
          <InputNumber
            :max="50"
            :min="1"
            v-model="config.initSpace"
            :formatter="value => `${value}%`"
            :parser="value => value.replace('%', '')"
          />
        </div>
      </div>
      <div class="label-value">
        <span>{{ $srv.getI18nByValue('位置') }}</span>
        <vxe-radio-group
          v-model="config.position"
          :disabled="!config.enable"
          @change="saveDetailToConfig"
        >
          <vxe-radio label="top" content="上"></vxe-radio>
          <vxe-radio label="bottom" content="下"></vxe-radio>
          <vxe-radio label="left" content="左"></vxe-radio>
          <vxe-radio label="right" content="右"></vxe-radio>
        </vxe-radio-group>
      </div>

      <div class="label-value">
        <span>{{ $srv.getI18nByValue('结束符') }}</span>
        <Input
          :placeholder="$srv.getI18nByValue('Default Enter...')"
          clearable
          v-model="config.terminator"
          :disabled="!config.enable"
          @on-change="saveDetailToConfig"
        />
      </div>
      <div class="label-value">
        <span>{{ $srv.getI18nByValue('公共API') }}</span>
        <o-m2o-selector
          v-model="config.apiName"
          :placeholder="
            $srv.getI18nByPath('piece.oQueryLinkSetting.commoneventlibrary')
          "
          @on-dochange="saveDetailToConfig"
          :tTable="$srv.globalVar.tableName.PUB_API"
          :tField="$srv.globalVar.fieldName.pubApiName"
          :vField="$srv.globalVar.fieldName.pubApiName"
          :dropdown="true"
        ></o-m2o-selector>
      </div>
    </div>
  </div>
</template>

<script lang="ts">
import { Component, Prop, Watch, Model, Vue } from 'vue-property-decorator';
import { Tsrv, T_srv } from '@/services';

@Component
export default class qbeSearchSetting extends Vue {
  @Model('modelchange') config: any;

  created() {}

  mounted() {}

  private saveDetailToConfig() {
    this.$emit('modelchange', this.config);
    this.$emit('change');
  }
}
</script>

<style scoped lang="scss">
.bancode-scan-setting {
  position: relative;
  .title {
    font-weight: bold;
    height: 36px;
    display: block;
    line-height: 36px;
  }
  .setting-item {
    display: flex;
    flex-direction: column;
    margin-left: 10px;
    .db-label-value {
      display: flex;
      flex-direction: row;
      justify-content: space-between;
    }
    .label-value {
      margin-bottom: 5px;
      display: flex;
      flex-direction: row;
      justify-content: flex-start;
      align-items: center;
      & > span {
        white-space: nowrap;
        &::after {
          content: '：';
          margin: 0 5px;
        }
      }
      ::v-deep.o-m2o-selector {
        flex: 1;
      }
    }
  }
}
</style>
